From 08eeb78bad10fe34a6013ae3c839ab9cfb642ff8 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Thu, 30 Jul 2026 17:07:09 +0000 Subject: [PATCH] Add the columns YKAge and YKID to REPRO_STATES --- .../sokwedb/indexes/create/repro_states.m4 | 7 +++- .../sokwedb/indexes/drop/repro_states.m4 | 2 + .../sokwedb/tables/create/repro_states.m4 | 5 +++ doc/src/analyzed/repro_states.m4 | 38 +++++++++++++++++++ doc/src/epilog.inc.m4 | 4 ++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/db/schemas/sokwedb/indexes/create/repro_states.m4 b/db/schemas/sokwedb/indexes/create/repro_states.m4 index 8665fd1..16492c4 100644 --- a/db/schemas/sokwedb/indexes/create/repro_states.m4 +++ b/db/schemas/sokwedb/indexes/create/repro_states.m4 @@ -38,5 +38,10 @@ CREATE INDEX IF NOT EXISTS repro_states_lactendcert ON repro_states CREATE INDEX IF NOT EXISTS repro_states_parity ON repro_states (parity); - +CREATE INDEX IF NOT EXISTS repro_states_ykage ON repro_states + (ykage) + WHERE ykage IS NOT NULL; +CREATE INDEX IF NOT EXISTS repro_states_ykid ON repro_states + (ykid) + WHERE ykid IS NOT NULL; diff --git a/db/schemas/sokwedb/indexes/drop/repro_states.m4 b/db/schemas/sokwedb/indexes/drop/repro_states.m4 index 441ede1..762c2b9 100644 --- a/db/schemas/sokwedb/indexes/drop/repro_states.m4 +++ b/db/schemas/sokwedb/indexes/drop/repro_states.m4 @@ -30,3 +30,5 @@ DROP INDEX IF EXISTS repro_states_estrusdaycert; DROP INDEX IF EXISTS repro_states_lactendcert; DROP INDEX IF EXISTS repro_states_parity; +DROP INDEX IF EXISTS repro_states_ykage; +DROP INDEX IF EXISTS repro_states_ykid; diff --git a/db/schemas/sokwedb/tables/create/repro_states.m4 b/db/schemas/sokwedb/tables/create/repro_states.m4 index 4f96ef0..9d93470 100644 --- a/db/schemas/sokwedb/tables/create/repro_states.m4 +++ b/db/schemas/sokwedb/tables/create/repro_states.m4 @@ -42,6 +42,11 @@ CREATE TABLE repro_states ( REFERENCES le_certainties ,parity TEXT NOT NULL REFERENCES parities + ,ykage INTEGER + nonnegative_check(`YKAge') + ,animid_type_column(`ykid', `YKID', `NULL') + + null_iff_null(`YKID', `YKage') ); grant_priv(`REPRO_STATES') diff --git a/doc/src/analyzed/repro_states.m4 b/doc/src/analyzed/repro_states.m4 index 95822a7..72db65c 100644 --- a/doc/src/analyzed/repro_states.m4 +++ b/doc/src/analyzed/repro_states.m4 @@ -40,6 +40,13 @@ between the |REPRO_STATES.AnimID|'s |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.EntryDate| and their |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.DepartDate|, inclusive of endpoints. +There must be information on both the female's youngest offspring's +age and the youngest offspring's identifier, or no information on +either. +This means that either the |REPRO_STATES.YKAge| and +|REPRO_STATES.YKID| values must both be |null|, or neither may be +|null|. + .. contents:: :depth: 2 @@ -176,3 +183,34 @@ Parity |REPRO_STATES.Parity_summary| |notnull| + + +.. _REPRO_STATES.YKAge: + +YKAge +````` + +.. |REPRO_STATES.YKAge_summary| replace:: + The age of the female's youngest offspring, as of the row's + |REPRO_STATES.Date| value. + Measured in units of (what are probably) whole days. + +|REPRO_STATES.YKAge_summary| +|nonnegative| + +This column may be |null|. See above for details. + + +.. _REPRO_STATES.YKID: + +YKID +```` + +.. |REPRO_STATES.YKID_summary| replace:: + The |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| value of the + female's youngest offspring as of the row's |REPRO_STATES.Date| + value. + +|REPRO_STATES.YKID_summary| + +This column may be |null|. See above for details. diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 8167a77..4dc9456 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -765,6 +765,10 @@ elo_ranks_daily_rst(sdb_male, MT)dnl :ref:`LactEndCert ` .. |REPRO_STATES.Parity| replace:: :ref:`Parity ` +.. |REPRO_STATES.YKAge| replace:: + :ref:`YKAge ` +.. |REPRO_STATES.YKID| replace:: + :ref:`YKID ` .. |REPRO_STATE_CHANGE_SOURCES| replace:: :ref:`REPRO_STATE_CHANGE_SOURCES ` -- 2.34.1